/********************************************
 * 功能说明: 
 * 模块名称: 
 * 系统名称: 
 * 软件版权: Frank
 * 系统版本: 1.0.0
 * 开发人员: Frank
 * 开发时间: 2019/9/19 15:29
 * 审核人员: 
 * 相关文档: 
 * 修改记录: 修改日期 修改人员 修改说明
 *********************************************/
package com.spring.arch.job.model;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 任务信息
 * @author Frank
 * @version 1.0.0.1
 * @since JDK 1.8
 */
@NoArgsConstructor
@Getter
@Setter
@Entity
@Table(name = "xxl_job_info")
public class JobInfo implements Serializable {

    private static final long serialVersionUID = 5884750616750043729L;
    /**
     * 主键id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(nullable = false, unique = true, insertable = false, updatable = false)
    private Integer id;

    /**
     * 执行器主键ID
     */
    @NotNull
    @Column(name = "job_group")
    private Integer jobGroup;

    /**
     * 任务执行CRON
     */
    @NotBlank
    @Size(max = 128)
    @Column(name = "job_cron", nullable = false)
    private String jobCron;

    /**
     * 任务描述
     */
    @NotBlank
    @Size(max = 255)
    @Column(name = "job_desc", nullable = false)
    private String jobDesc;

    /**
     * 创建任务时间
     */
    @Column(name = "add_time")
    private LocalDateTime addTime;

    /**
     * 更新任务时间
     */
    @Column(name = "update_time")
    private LocalDateTime updateTime;

    /**
     * 作者
     */
    @Size(max = 64)
    @Column(name = "author")
    private String author;

    /**
     * 报警邮件
     */
    @Size(max = 255)
    @Column(name = "alarm_email")
    private String alarmEmail;

    /**
     * 执行器路由策略
     */
    @Size(max = 50)
    @Column(name = "executor_route_strategy")
    private String executorRouteStrategy = "FIRST";

    /**
     * 执行器任务handler
     */
    @NotBlank
    @Size(max = 255)
    @Column(name = "executor_handler", nullable = false)
    private String executorHandler;

    /**
     * 执行器任务参数
     */
    @Size(max = 512)
    @Column(name = "executor_param")
    private String executorParam;

    /**
     * 阻塞处理策略
     */
    @Size(max = 50)
    @Column(name = "executor_block_strategy")
    private String executorBlockStrategy = "SERIAL_EXECUTION";

    /**
     * 任务执行超时时间，单位秒
     */
    @NotNull
    @Min(0)
    @Column(name = "executor_timeout")
    private int executorTimeout = 0;

    /**
     * 失败重试次数
     */
    @NotNull
    @Min(0)
    @Column(name = "executor_fail_retry_count")
    private int executorFailRetryCount = 0;

    /**
     * GLUE类型
     */
    @NotBlank
    @Size(max = 50)
    @Column(name = "glue_type", nullable = false)
    private String glueType;

    /**
     * GLUE源代码
     */
    @Column(name = "glue_source", columnDefinition = "mediumtext COMMENT 'GLUE源代码'")
    private String glueSource;

    /**
     * GLUE备注
     */
    @Size(max = 128)
    @Column(name = "glue_remark")
    private String glueRemark;

    /**
     * GLUE更新时间
     */
    @Column(name = "glue_updatetime")
    private LocalDateTime glueUpdateTime;

    /**
     * 子任务ID，多个逗号分隔
     */
    @Size(max = 255)
    @Column(name = "child_jobid")
    private String childJobId;

    /**
     * 调度状态：0-停止，1-运行
     */
    @NotNull
    @Column(name = "trigger_status", columnDefinition = "tinyint(4) NOT NULL DEFAULT '0' COMMENT '调度状态：0-停止，1-运行'")
    private int triggerStatus = 0;

    /**
     * 上次调度时间
     */
    @NotNull
    @Column(name = "trigger_last_time", columnDefinition = "bigint(13) NOT NULL DEFAULT '0' COMMENT '上次调度时间'")
    private long triggerLastTime = 0;

    /**
     * 下次调度时间
     */
    @NotNull
    @Column(name = "trigger_next_time", columnDefinition = "bigint(13) NOT NULL DEFAULT '0' COMMENT '下次调度时间'")
    private long triggerNextTime = 0;

}